//
//  HYOUHotCollectionViewCell.m
//  BestGift
//
//  Created by 温晓宇 on 15/12/29.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "HYOUHotCollectionViewCell.h"

@interface HYOUHotCollectionViewCell ()

@property(nonatomic, retain) HYOUBaseView *view;
@property(nonatomic, retain) UIImageView *imageView;
@property(nonatomic, retain) UILabel *nameLabel;
@property(nonatomic, retain) UILabel *moneyLabel;
@property(nonatomic, retain) UILabel *likeLabel;

@end

@implementation HYOUHotCollectionViewCell
-(void)dealloc{
    [_view release];
    [_imageView release];
    [_nameLabel release];
    [_moneyLabel release];
    [_likeLabel release];
    [_model release];
    [super dealloc];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    self.view = [[HYOUBaseView alloc] initWithFrame:CGRectMake(0, 0, (WIDTH - 30) / 2, (WIDTH - 30) / 2 + 50)];
//    self.view.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.view];
    self.view.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.view.layer.borderWidth = 1;
    [_view release];
    
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 70)];
//    self.imageView.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:self.imageView];
    [_imageView release];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, self.imageView.frame.size.height + 10, self.view.frame.size.width - 10, 25)];
    self.nameLabel.text = @"dsafas";
    self.nameLabel.font = [UIFont systemFontOfSize:14];
//    self.nameLabel.textColor = RGBA(231, 46, 67, 1);
    [self.view addSubview:self.nameLabel];
    [_nameLabel release];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, self.view.frame.size.height - 25, self.view.frame.size.width - 80, 25)];
    self.moneyLabel.text = @"21312312";
//    self.moneyLabel.backgroundColor = [UIColor cyanColor];
    self.moneyLabel.textColor = RGBA(231, 46, 67, 1);
    [self.view addSubview:self.moneyLabel];
    [_moneyLabel release];
    
    self.likeLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.view.frame.size.width / 2) + 45, self.view.frame.size.height - 25, 35, 25)];
    self.likeLabel.text = @"1234";
    self.likeLabel.textColor = [UIColor grayColor];
    //    self.likeLabel.backgroundColor = [UIColor redColor];
    self.likeLabel.font = [UIFont systemFontOfSize:12];
//    self.likeLabel.textColor = [UIColor redColor];
    [self.view addSubview:self.likeLabel];
    [_likeLabel release];
    
}
-(void)setModel:(HYOUHotModel *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.nameLabel.text = _model.name;
    self.moneyLabel.text = _model.price;
    NSString *like = [NSString stringWithFormat:@"%@",_model.favorites_count];
    self.likeLabel.text = like;
    
    NSURL *url = [NSURL URLWithString:_model.cover_image_url];
    [self.imageView sd_setImageWithURL:url];
    
}

@end
